package com.hyb.weibo.user.controller;

import com.hyb.weibo.common.vo.JsonResult;
import com.hyb.weibo.user.pojo.User;
import com.hyb.weibo.user.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserServiceImpl userService;

    @RequestMapping("/findAll")
    public JsonResult findAll(){
        return JsonResult.ok(userService.findAll());
    }

    @RequestMapping("/findById")
    public JsonResult findById(String id){
        return JsonResult.ok(userService.findById(id));
    }

    @RequestMapping("/regUser")
    public JsonResult regUser(User u){
        return  userService.regUser(u);
    }

    @RequestMapping("/login")
    public JsonResult login(User u){
        return  userService.login(u);
    }
}
